
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./templates/template_acheteur.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <f:view>
            <c:if test="${userBean.acheteurConnected == false}">
                Veuillez vous connecter pour accéder à cette partie
            </c:if>
            <c:if test="${userBean.acheteurConnected == true}">
                <h1>Les produits</h1>
                <h:form id="form1" style="height: 230px;"> 
                    <fieldset style="width: 360px; margin-left: auto; margin-right: auto;">
                        <legend>Recherche avancée :</legend>
                        <h:panelGrid columns="2" style="width: 100%;">
                            <h:outputLabel>Mot clé</h:outputLabel>
                            <p:inputText style="width: 190px;" id="inputsearch" 
                                         value="#{magasinBean.searchacheteur}" label="inputsearch">  

                            </p:inputText>  
                            <h:outputLabel>Catégorie</h:outputLabel>
                            <h:selectOneMenu id="categorie" style="width: 200px;" value="#{magasinBean.categorie}">
                                <f:selectItem itemLabel="" itemValue="" />
                                <f:selectItem itemLabel="Mode" itemValue="Mode" />
                                <f:selectItem itemLabel="High-Tech" itemValue="High-Tech" />
                                <f:selectItem itemLabel="Maison, Jardin, Bricolage" itemValue="Maison, Jardin, Bricolage" />
                                <f:selectItem itemLabel="Livre, Cinéma, Musique" itemValue="Livre, Cinéma, Musique" />
                                <f:selectItem itemLabel="Loisir" itemValue="Loisir" />
                                <f:selectItem itemLabel="Collections" itemValue="Collections" />
                                <f:selectItem itemLabel="Auto, Moto, Bateau" itemValue="Auto, Moto, Bateau" />
                                <f:selectItem itemLabel="Immobilier" itemValue="Immobiler" />
                            </h:selectOneMenu>
                            <h:outputLabel>Contrainte géographique</h:outputLabel>
                            <h:selectOneMenu style="width: 200px" value="#{magasinBean.distance}">
                                <f:selectItem itemLabel="" itemValue="" />
                                <f:selectItem itemLabel="Dans un rayon de 15km" itemValue="15" />
                                <f:selectItem itemLabel="Dans un rayon de 30km" itemValue="30" />
                            </h:selectOneMenu>
                            <h:outputLabel></h:outputLabel>
                            <h:commandButton value="Valider" style="float: right;" id="btnAdd"  action="#{magasinBean.btnsrchacheteur}" />
                        </h:panelGrid>
                        <hr/>
                        <h:panelGrid columns="2" style="width: 100%;">
                            <h:outputLabel>Vendeur (nom)</h:outputLabel>
                            <p:inputText style="float: right; width: 190px;" value="#{magasinBean.searchvendeur}" label="inputsearch">     
                            </p:inputText>  
                            <h:outputLabel></h:outputLabel>
                            <h:commandButton value="Valider" style="float: right;"  action="#{magasinBean.btnsrchvendeur}" />
                        </h:panelGrid>
                    </fieldset>
                </h:form>
                <p:dataTable value="#{magasinBean.lazyProduit}" 
                             var="val"
                             rows="10"
                             paginator="true"
                             rowsPerPageTemplate="5,10,15"
                             paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                             id="DTTableLazy"
                             lazy="true"
                             >

                    <p:column headerText="Nom" style="width: 180px; text-align: center;">
                        <h:outputText value="#{val.nom}"/>
                    </p:column>
                    <p:column headerText="Description">
                        <h:outputText value="#{val.description}"/>
                    </p:column>
                    <p:column headerText="Catégorie" style="width: 160px; text-align: center;">
                        <h:outputText value="#{val.categorie}"/>
                    </p:column>
                    <p:column headerText="Vendeur" style="width: 200px; text-align: center;">
                        <p:commandLink value="#{val.magasin.proprio.prenom} #{val.magasin.proprio.nom}" action="#{userBean.showVendeur(val.magasin.proprio)}"/>
                    </p:column>
                    <p:column sortBy="#{val.prix}" headerText="Prix" style="width: 120px; text-align: center;">
                        <h:outputText value="#{val.prix} €"/>
                    </p:column>
                    <p:column headerText="E-Mall" style="width: 100px; text-align: center;" >
                        <h:form id="formpanier">
                            <h:commandLink action="#{magasinBean.goToPanier(val)}" value="Ajouter" ></h:commandLink>
                        </h:form>
                    </p:column>
                </p:dataTable>
            </c:if>
        </f:view>
    </ui:define>
</ui:composition>
